package com.nalanalana.spring6.validator.one;

import org.springframework.validation.BindingResult;
import org.springframework.validation.DataBinder;

/**
 * @Project ：learn_spring
 * @File ：TestPerson.java
 * @IDE ：IntelliJ IDEA
 * @Author ：自由如风间
 * @Date ：2025/4/6 20:52
 * @Description ：测试PersonValidator
 */

public class TestPerson {

    public static void main(String[] args) {
        Person person = new Person("王森", 777);
        DataBinder dataBinder = new DataBinder(person);
        // 设置校验器
        dataBinder.setValidator(new PersonValidator());
        // 执行校验
        dataBinder.validate();
        // 输出校验结果
        BindingResult result = dataBinder.getBindingResult();
        System.out.println(result.getAllErrors());
    }
}
